<?php

namespace frontend\modules\shop\controllers;

use Yii;
use frontend\components\Controller;
use common\logics\ShopCategoryLogic;
use frontend\modules\shop\models\ProductSearch;

/**
 * 商城分类相关接口
 * ProfileController for the `shop` module
 */
class CategoryController extends Controller {

    /**
     * Declares the allowed HTTP verbs.
     * Please refer to [[VerbFilter::actions]] on how to declare the allowed verbs.
     * @return array the allowed HTTP verbs.
     */
    protected function verbs() {
        return [
            '*' => ['GET']
        ];
    }

    /**
     * @inheritdoc
     */
    public function actionIndex() {
        return ShopCategoryLogic::getCategoryTree();
    }

    /**
     * @inheritdoc
     */
    public function actionList($id) {
        return ShopCategoryLogic::categoryLayer($id);
    }

    /**
     * @inheritdoc
     */
    public function actionView($id) {
        /* @var $modelClass \frontend\modules\shop\models\ProductSearch */
        $modelClass = new ProductSearch();
        return $modelClass->search($id);
    }

}
